package com.usian.feign;

import com.usian.fallback.ItemServiceFallBack;
import com.usian.pojo.*;
import com.usian.utils.CatResult;
import com.usian.utils.PageResult;
import com.usian.utils.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@FeignClient(value = "usian-item-service",fallbackFactory = ItemServiceFallBack.class)
public interface ItemServiceFeign {

    /**
     * 商品详情页规格参数接口
     *
     * @param itemId
     * @return
     */
    @RequestMapping("/service/item/selectTbItemParamItemByItemId")
    public TbItemParamItem selectTbItemParamItemByItemId(@RequestParam Long itemId);

    /**
     * 6.商品详情页商品介绍接口
     *
     * @param itemId
     * @return
     */
    @RequestMapping("/service/item/selectItemDescByItemId")
    public TbItemDesc selectItemDescByItemId(@RequestParam Long itemId);

    @RequestMapping("/service/itemCategory/selectItemCategoryAll")
    CatResult selectItemCategoryAll();

    /**
     * 规格模板查询接口
     *
     * @return
     * @param pages
     * @param rows
     */
    @RequestMapping("/service/itemParam/selectItemParamAll")
    PageResult selectItemParamAll(@RequestParam Integer pages,
                                  @RequestParam Integer rows);

    /**
     * 商品的删除
     */
    @RequestMapping("/service/item/deleteTbItem")
    Integer deleteTbItem(@RequestParam Long itemId);

    /**
     * 商品的修改回显
     */
    @RequestMapping("/service/item/preUpdateItem")
    Map<String,Object> preUpdateItem(@RequestParam Long itemId);

    /**
     * 商品的添加
     */
    @RequestMapping("/service/item/insertTbItem")
    public Integer insertTbItem(@RequestBody TbItem tbItem, @RequestParam String desc,
                                @RequestParam String itemParams);

    /**
     * 修改的添加
     */
    @RequestMapping("/service/item/updateTbItem")
    public Integer updateTbItem(@RequestBody TbItem tbItem, @RequestParam("desc") String desc,
                                @RequestParam("itemParams") String itemParams);

    /**
     * 根据商品分类 ID 查询规格参数模板
     */
    @RequestMapping("/service/itemParam/selectItemParamByItemCatId")
    TbItemParam selectItemParamByItemCatId(@RequestParam Long itemCatId);

    /**
     * 商品列表查询
     * @param page
     * @param rows
     * @return
     */
    @RequestMapping("/service/item/selectTbItemAllByPage")
    PageResult selectTbItemAllByPage(@RequestParam Integer page,
                                     @RequestParam Integer rows);

    /**查询商品信息
     * 根据商品id
     * @param itemId
     * @return
     */
    @RequestMapping("/service/item/selectItemInfo")
    TbItem selectItemInfo(@RequestParam Long itemId);

    /**
     * 查询子节点下拉框
     * @param id
     * @return
     */
    @RequestMapping("/service/itemCategory/selectItemCategoryByParentId")
    List<TbItemCat> selectItemCategoryByParentId(@RequestParam Long id);

    /**
     * 商品规格模板添加接口
     *
     * @param itemCatId
     * @param paramData
     * @return
     */
    @RequestMapping("/service/itemParam/insertItemParam")
    Integer insertItemParam(@RequestParam("itemCatId") Long itemCatId,@RequestParam("paramData") String paramData);

    @RequestMapping("/service/itemParam/deleteItemParamById")
    Integer deleteItemParamById(@RequestParam("id") Long id);
}
